<template>
  <div>
    <el-dialog
      :title="formData.id?'编辑房产':'添加房产'"
      :visible="showDialog"
      @close="btnCancel"
    >
      <el-form ref="formData" :model="formData">
        <el-form-item label="经纪" prop="agent">
          <el-select v-model="agentValue" placeholder="全部经纪">
            <el-option v-for="item in agentOption" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="分类" prop="category">
          <el-select v-model="categoryValue" placeholder="全部分类">
            <el-option v-for="item in categoryOption" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item required label="标题" prop="title">
          <el-input v-model="formData.title" style="width:90%" />
        </el-form-item>
        <el-form-item label="标签" prop="tags">
          <!-- 判断是否有数据才显示 -->
          <el-tag
            v-for="tag in formData.tags"
            :key="tag"
            closable
            :disable-transitions="false"
            @close="handleClose(tag)"
          >
            {{ tag }}
          </el-tag>
          <!-- 输入添加 -->
          <el-input
            v-if="inputVisible"
            ref="saveTagInput"
            v-model="inputValue"
            class="input-new-tag"
            size="small"
            @keyup.enter.native="handleInputConfirm"
            @blur="handleInputConfirm"
          />
          <el-button v-else class="button-new-tag" size="small" @click="showInput">+ 新标签</el-button>

        </el-form-item>
        <el-form-item label="地址" prop="tags">
          <el-cascader
            v-model="selectedOptions"
            style="width:150px"
            size="large"
            :options="options"
            @change="handleChange"
          />
          <el-input v-model="formData.address" style="width:525px" />
        </el-form-item>
        <el-form-item label="价格" prop="price">
          <el-input v-model="formData.price" style="width:90%" />
        </el-form-item>
        <el-form-item required label="描述" prop="desc">
          <el-input v-model="formData.desc" type="textarea" :autosize="{ minRows: 3}" style="width:90%" />

        </el-form-item>
        <el-form-item label="内容" prop="content">
          <wangEnduit
            v-model="formData.content"
            style="marginLeft:40px;width:680px"
            :is-clear="isClear"
            :value="formData.content"
            @change="change"
          />
        </el-form-item>
        <el-form-item label="介绍图片" prop=" photos">
          <el-upload
            action="https://jsonplaceholder.typicode.com/posts/"
            list-type="picture-card"
            :on-preview="handlePictureCardPreview"
            :on-remove="handleRemove"
          >
            <i class="el-icon-plus" />
          </el-upload>
          <el-dialog :visible.sync="dialogVisible">
            <img width="100%" :src="image" alt="">
          </el-dialog>
        </el-form-item>

        <el-form-item label="封面" prop="image">
          <imageUpload ref="imageUpload" />
        </el-form-item>
      </el-form>
      <!-- footer插槽 -->
      <template v-slot:footer>
        <el-row type="flex" justify="center">
          <el-col :span="6">
            <el-button size="small" @click="btnCancel">取消</el-button>
            <el-button type="primary" size="small" @click="btnOk">确定</el-button>
          </el-col>
        </el-row>
      </template>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
    }
  }
}
</script>

<style>
</style>
